#define _CRT_SECURE_NO_WARNINGS 1

#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int com_int(const void* p1, const void* p2)
{
	return *((int*)p1) - *((int*)p2);
}

void print(int arr[10], int sz)
{
	for (int i = 0; i < sz; i++)
	{
		printf("%d ", arr[i]);
	}
}

//int main()
//{
//	int arr[10] = { 9,8,7,6,5,4,3,2,1,0 };
//	int sz = sizeof(arr) / sizeof(arr[0]);
//	qsort(arr, sz, sizeof(arr[0]), com_int);
//	print(arr, sz);
//	return 0;
//}

struct Stu
{
	char name[20];
	int age;
	double weight;
};

int com_name(const void* p1, const void* p2)
{
	return strcmp(((struct Stu*)p1)->name, ((struct Stu*)p2)->name);
}

//int main()
//{
//	struct Stu arr[] = { {"zhangsan",20,55.5},{"lisi",17,58.2},{"wangwu",25,60.0} };
//	int sz = sizeof(arr) / sizeof(arr[0]);
//	qsort(arr, sz, sizeof(arr[0]), com_name);
//	//print(arr, sz);
//	return 0;
//}

int com_age(const void* p1, const void* p2)
{
	return ((struct Stu*)p1)->age - ((struct Stu*)p2)->age;
}


//int main()
//{
//	struct Stu arr[] = { {"zhangsan",20,55.5},{"lisi",17,58.2},{"wangwu",25,60.0} };
//	int sz = sizeof(arr) / sizeof(arr[0]);
//	qsort(arr, sz, sizeof(arr[0]), com_age);
//	//print(arr, sz);
//	return 0;
//}

int com_weight(const void* p1, const void* p2)
{
	return ((struct Stu*)p1)->weight- ((struct Stu*)p2)->weight;
}

int main()
{
	struct Stu arr[] = { {"zhangsan",20,55.5},{"lisi",17,58.2},{"wangwu",25,60.0} };
	int sz = sizeof(arr) / sizeof(arr[0]);
	qsort(arr, sz, sizeof(arr[0]), com_weight);
	//print(arr, sz);
	return 0;
}